package kr.hkit.powerjava.chapter25;

import java.io.*;
import java.net.*;

public class URLPostTest { //get, post방식..중 post
	public static void main(String[] args) {
		/*http://hkit.kr/SUB/?ctId=22*/
		 try {
			URL url = new URL("http://hkit.kr/SUB/");
			URLConnection connection = url.openConnection();
			connection.setDoOutput(true);
			
			OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
			out.write("ctId=22" + 1);
			out.close();
			
			BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));//두번째꺼 선택 try..
			String line;
			while((line=in.readLine()) !=null){
				System.out.println(line);
			}
			in.close();
			
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
